﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;


public class UI : MonoBehaviour {
	Gamemanager gameM;
	public GameObject text;
	public GameObject gameopen;
	float levelStartDelay=1.5f;
	public GameObject opentext;
	void gamestart(){
		print ("level"+gameM.Level);
		//gameopen = GameObject.Find ("gameopen");
		//opentext = GameObject.Find ("open");
		//text = GameObject.Find ("level");
		opentext.GetComponent<Text>().text="LEVEL "+gameM.Level;
		text.GetComponent<Text> ().text="LEVEL "+gameM.Level;
		gameopen.SetActive (true);
		Invoke("Hideopenimage", levelStartDelay);
		
	}
	void Hideopenimage(){
		gameopen.SetActive (false);
		Gamemanager.gamesSTR = true;
	}


	// Use this for initialization
	void Start () {
		Gamemanager.gamesSTR = false;
		gameM=GameObject.Find("game manager").GetComponent<Gamemanager>();
		gamestart ();
	
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetKeyDown (KeyCode.R)) {
			gameM.Level--;
			Application.LoadLevel (Application.loadedLevel);
			
		}
	
	}
}
